import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
/*这个注解就把这个HelloServlet类和HTTP请求中的URL里面路径带有/hello这样的请求关联起来*/
@WebServlet("/hello")
//HttpServlet这个类来自于我们之前引入的依赖servlet
public class HelloServlet extends HttpServlet {
    // 在tomcat收到一个HTTP的GET请求时，会被Tomcat调用到
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /*必须干掉父类的doGet方法*/
        /*super.doGet(req, resp);*/
        /*在控制台打印*/
        System.out.println("hello world");
        /*返回请求在页面显示*/
        resp.getWriter().write("hello world" + System.currentTimeMillis());
    }
}
